package be.idamf.mx.rpc.dto
{
	import be.idamf.flash.events.dispatchEventOn;
	
	import flash.events.Event;

	[Event(name="change", type="flash.events.Event")]
	[RemoteClass(alias="be.idamf.flex.remoting.dto.TimeTransfer")]
	public class TimeTransfer
	{
		public function TimeTransfer()
		{
		}

		private var _year:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get year():Number
		{
			return _year;
		}
		public function set year(value:Number):void
		{
			_year = value;
		}
		
		private var _month:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get month():Number
		{
			return _month;
		}
		public function set month(value:Number):void
		{
			_month = value;
		}
		
		private var _day:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get day():Number
		{
			return _day;
		}
		public function set day(value:Number):void
		{
			_day = value;
		}
		
		private var _hours:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get hours():Number
		{
			return _hours;
		}
		public function set hours(value:Number):void
		{
			_hours = value;
		}
		
		private var _minutes:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get minutes():Number
		{
			return _minutes;
		}
		public function set minutes(value:Number):void
		{
			_minutes = value;
		}

		private var _seconds:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get seconds():Number
		{
			return _seconds;
		}
		public function set seconds(value:Number):void
		{
			_seconds = value;
		}

		private var _milliseconds:Number;
		[Bindable]
		[ChangeEvent("change")]
		public function get milliseconds():Number
		{
			return _milliseconds;
		}
		public function set milliseconds(value:Number):void
		{
			_milliseconds = value;
		}
		
		////////////////////////////////////////////////////////////////////////

		public function getDate():Date
		{
			return new Date(year, month, day, hours, minutes, seconds, milliseconds);
		}
		
		public function setDate(value:Date):void
		{
			_year = value.getFullYear();
			_month = value.getMonth();
			_day = value.getDate();
			_hours = value.getHours();
			_minutes = value.getMinutes();
			_seconds = value.getSeconds();
			_milliseconds = value.getMilliseconds();
			
			dispatchEventOn(this, Event.CHANGE);
		}
	}
}